﻿using System;
using System.Text;

namespace GPS.GPSLanguage
{
    class SpeedToken
    {
        internal static void ParseLanguage(GPSData gpsData, System.Collections.Queue q)
        {
            String valToken = (string)q.Dequeue();
            double val = 0;

            try
            {
                if (valToken.Length > 0)
                    val = double.Parse(valToken);
            }
            catch
            {

            }

            gpsData.SetSpeed(val);

            switch (gpsData.MessageType)
            {
                case MessageType.GPRMC:
                    TrackAngleToken.ParseLanguage(gpsData, q);
                    break;
                default:
                    throw new InvalidLanguageException("How did you get here?");
            }
        }
    }
}
